package com.eco.fanliapp.controller.app;

import com.eco.fanliapp.common.constant.ApiEnum;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.service.ITaoBaoMethodService;
import com.eco.fanliapp.utils.ApiUtils;
import com.eco.fanliapp.utils.JsonUtils;
import com.eco.fanliapp.vo.HaoDanKuSearchInfo;
import com.eco.fanliapp.vo.respone.ResponeResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mobile/goodsCommend")
public class RecommendedController {

//	@Autowired
//	private ITaoBaoService taoBaoService;
	@Autowired
	private ITaoBaoMethodService taoBaoMethodService;
	
	@GetMapping("/list")
	public ServerResponse<ResponeResults> commended(){
		StringBuilder param = new StringBuilder();
		param.append("sale_type/").append(1);//实时榜单
		param.append("/cid/").append(0);
		param.append("/min_id/").append(1);
		param.append("/back/").append(50);
		String str = ApiUtils.getData(ApiEnum.SALES_LIST, param.toString());
		HaoDanKuSearchInfo info =  JsonUtils.getJsonToBean(str, HaoDanKuSearchInfo.class);
		if(info != null && info.getCode() == 1 && info.getData().size() > 0){
			ResponeResults results = taoBaoMethodService.ItemMethon2(info,null);
			if(results != null) {
				return ServerResponse.createBySuccess("数据获取成功", results);
			}else {
				return ServerResponse.createBySuccessCodeMessage(201,"暂无数据");
			}
		}else {
			return ServerResponse.createBySuccessCodeMessage(201,"暂无数据");
		}
	}

}
